/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sengine;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.lwjgl.LWJGLException;
import static org.lwjgl.opengl.GL11.*;

public class SpriteTest extends GLGame {

    private int x, y;
    private Sprite sprite;

    public static void main(String[] args) throws LWJGLException {
        (new SpriteTest()).run();
    }
    
    public SpriteTest() {
        sprite = new Sprite(30, 0, 50, 50);
        sprite.setAx(10);
        sprite.setVr(3);
        try {
            sprite.setTexture(Texture.loadTexture(ImageIO.read(new File("jump.gif"))));
        } catch (IOException ex) {
            Logger.getLogger(SpriteTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    protected void render(long millis) {
       

        // Create a new draw matrix for custom settings.
        glPushMatrix();
        {
            // Translate to the location.
            glTranslatef(x, y, 0);

            // Begin drawing with QUADS. A QUAD is a polygon with four vertices.
            glBegin(GL_QUADS);
            glVertex2f(0, 0);
            glColor3f(1, 1, 0);
            glVertex2f(0, 60);
            glColor3f(1, 0, 1);
            glVertex2f(80, 60);
            glColor3f(1, 0, 0);
            glVertex2f(80, 0);
            glColor3f(1, 1, 1);
            glEnd();  // End the drawing.
        }
        glPopMatrix();  // Restore original settings.
        x+=1;
        y+=1;
        
        sprite.update(millis);
        sprite.render();
        fatalErrorCheck();
    }

    @Override
    protected void keyEvent(int key, boolean down) {
    }
}
